<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/10/22
  Time: 9:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>获取身份证号中的生日</title>
</head>
<%!
    public String getBirthday(String str){
        String birthday="";
        if(str.length()==18){
            String year = str.substring(6,10);
            String month = str.substring(10,12);
            String day = str.substring(12,14);
            birthday = year+"-"+month+"-"+day;
        }
        return birthday;
    }
%>
<body>
<table border="1">
    <tr>
        <td>身份证号</td>
        <td>生日</td>
    </tr>
    <tr>
        <td>130223200203193002</td>
        <td><%=getBirthday("130223200203193002") %></td>
    </tr>
    <tr>
        <td>130223200305193002</td>
        <td><%=getBirthday("130223200305193002") %></td>
    </tr>
</table>
</body>
</html>
